package experiment_third;

import java.util.Scanner;

import experiment_two.Course;
import experiment_two.Student;
import experiment_two.Teacher;

public class MAIN {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
//		Course c1,c2;
//		Student s1,s2;
//		Teacher t1,t2;
		couse c1,c2;
		Tea t1,t2;
		Stu s1,s2;
		String inf [] [] = new String [2][9];//学生信息
		System.out.println("设定教师信息：");
		c1 = new couse("1", "高等数学", "教102", "周三上午");//课程对象实例化
		c2 = new couse("2", "线性代数", "教207", "周四下午");
		t1 = new Tea("123", "曹晓东", "男", c1);//教师对象实例化
		t2 = new Tea("124", "冯媛", "女", c2); 
		//把教师的信息和课程的信息分别放到两个二维数组里面
		String tea [] []= {{t1.get_number(),t1.get_name(),t1.get_sex(),t1.get_couse()},
						{t2.get_number(),t2.get_name(),t2.get_sex(),t2.get_couse()}};
		String cou [] [] = {{c1.get_number(),c1.get_course_name(),c1.get_place(),c1.get_time(),},
				           {c2.get_number(),c2.get_course_name(),c2.get_place(),c2.get_time()}};
		//打印基本信息
		for(int i = 0;i<2;i++) {
				System.out.println(tea[i][0]+','+tea[i][1]+','+tea[i][2]+','+tea[i][3]);
		}
		for(int i = 0;i<2;i++) {
			System.out.println(cou[i][0]+','+cou[i][1]+','+cou[i][2]+','+cou[i][3]);
		}
		Scanner in = new Scanner(System.in);
		System.out.println("现在开始选课，请输入课程名称和是否选课");

		//System.out.println(a);
		//退选课
		while(true) {
			//输入“开始选课”
			String c = in.nextLine();
			if(c.equals("开始选课")) {
				for(int i = 0;i<2;i++) {
					System.out.println("选择课程");
					String a = in.nextLine();
					System.out.println("选择状态");
					String b = in.nextLine();
					if(b.equals("选课")) {//判断状态
						for(int k = 0;k<2;k++) {
						if (a.equals(cou[k][1])) {//遍历寻找课程信息并保存在inf这个二维数组里面
							for(int z = 0;z<2;z++) {
								if(a.equals(tea[z][3])) {
									s1 = new Stu("2021310***","李四","男",cou[i][1],b);
									inf[k][0] = s1.get_number();
									inf[k][1] = s1.get_name();
									inf[k][2] = s1.get_sex();
									inf[k][3] = s1.get_couse();
									inf[k][4] = tea[z][1];
									inf[k][5] = cou[k][2];
									inf[k][6] = cou[k][3];
									inf[k][7] = s1.get_status();
									System.out.println("选课成功");
									break;
								}
							}
						}
						}
					}else if (b.equals("退课")) {
						for(int k = 0;k<2;k++) {
						if (a.equals(cou[k][1])) {
							for(int j = 0;j<2;j++) {
								if (a.equals(tea[j][3])) {
									s2 = new Stu("2021310***","李四","男",cou[i][1],b);
									inf[k][0] = s2.get_number();
									inf[k][1] = s2.get_name();
									inf[k][2] = s2.get_sex();
									inf[k][3] = s2.get_couse();
									inf[k][4] = tea[k][1];
									inf[k][5] = cou[k][2];
									inf[k][6] = cou[k][3];
									inf[k][7] = s2.get_status();
									System.out.println("退课成功");
									break;
								}
							}
							
						}
					}
					}
					
					
					}
			}else {
				System.out.println("终止选课");
				break;
			}
			System.out.println("打印学生信息");
			for(int i = 0;i<2;i++) {
				System.out.println(inf[i][0]+','+inf[i][1]+','+inf[i][2]+','
						+inf[i][3]+','+inf[i][4]+','+inf[i][5]+','+inf[i][6]
								+','+inf[i][7]);
			}
		}
			
	}

}
